﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace JSC.Portal.Entities
{
    public partial class Language
    {
        public static IList<Language> GetLanguages()
        {
            IList<Language> result = new List<Language>();
            foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
            {
                result.Add(new Language(ci.Name, ci.DisplayName));
            }
            return result;
        }

        public string GetNativeLanguageTextFromCulture()
        {
            CultureInfo ci = new CultureInfo(Culture);
            return ci.NativeName.Substring(0, ci.NativeName.IndexOf("(") - 1);
        }

        public string GetCountryFromCulture()
        {
            return Culture.Substring(3);
        }

        public string GetLanguageFromCulture()
        {
            CultureInfo ci = new CultureInfo(Culture);
            return ci.TwoLetterISOLanguageName;
        }
    }
}
